<template>
  <div>
    <el-form inline :model="queryData" ref="queryData" class="query-form">
      <el-form-item label="报备单号:" prop="orderNo">
        <el-input v-model="queryData.orderNo" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('orderNo')"/>
      </el-form-item>
      <el-form-item label="企业名称:" prop="enterpriseName">
        <el-input v-model="queryData.enterpriseName" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('enterpriseName')"/>
      </el-form-item>
      <el-form-item label="园区:" prop="gardenName">
        <el-input v-model="queryData.gardenName" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('gardenName')"/>
      </el-form-item>
      <el-form-item label="房源名称:" prop="housingName">
        <el-input v-model="queryData.housingName" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('housingName')"/>
      </el-form-item>
      <el-form-item label="带看名称:" prop="takeaLookName">
        <el-input v-model="queryData.takeaLookName" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('takeaLookName')"/>
      </el-form-item>
      <el-form-item label="报备状态:" prop="reportingState">
        <el-select v-model="queryData.reportingState" placeholder="请选择" clearable @clear="formClear('reportingState')"
                   style="width: 200px">
          <el-option :label="item" :value="index" v-for="(item, index) in stateArr" :key="index"/>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查 询</el-button>
        <el-button @click="onReset">重 置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableList" border style="width: 100%;">
      <el-table-column prop="orderNo" label="报备单号" align="center" show-overflow-tooltip/>
      <el-table-column prop="enterpriseName" label="企业名称" align="center"/>
      <el-table-column prop="customerName" label="企业联系人" align="center" show-overflow-tooltip/>
      <el-table-column prop="customerMobile" label="企业联系方式" align="center" width="150"/>
      <el-table-column prop="gardenName" label="园区" align="center"/>
      <el-table-column prop="housingName" label="房源名称" align="center" width="150" show-overflow-tooltip/>
      <el-table-column prop="takeaLookName" label="带看经纪人名称" align="center" width="150"/>
      <el-table-column prop="husingAgentName" label="房源经纪人名称" align="center" width="150"/>
      <el-table-column prop="husingAgentPhone" label="房源联系方式" align="center" width="150"/>
      <el-table-column prop="lookHousingStatusString" label="报备状态" align="center" width="150"/>
      <el-table-column label="操作" align="center" width="150">
        <template slot-scope="{row}">
          <router-link :to="`/reportManage/reportDetail?id=${row.id}`" class="el-link--primary">查 看</router-link>
        </template>
      </el-table-column>
    </el-table>
    <Paging v-model="queryData" @change="getRequest"></Paging>
  </div>
</template>

<script>
  export default {
    name: 'reportList',
    data() {
      return {
        stateArr: ['等待确认', '等待看房', '看房完成', '发放佣金', '报备失败', '报备超时'],
        tableList: [],
        queryData: {
          enterpriseName: null, // 企业名字
          gardenName: null, // 园区名字
          housingName: null, // 房源名字
          orderNo: null, // 报备单号
          reportingState: null, // 报备状态
          takeaLookName: null, // 带看名称
          pageNum: 1,
          pageSize: 10,
          total: 0
        }
      }
    },
    beforeMount() {
      this.getRequest()
    },
    methods: {
      onReset() {
        this.queryData.pageNum = 1
        this.$refs['queryData'].resetFields()
        this.getRequest()
      },
      async onSubmit() {
        this.queryData.pageNum = 1
        this.getRequest()
      },
      async getRequest() {
        const formData = JSON.parse(JSON.stringify(this.queryData))
        const res = await this.$ajax.get('/workorder/lookHousingOrder/backstage/list', { params: formData })
        this.queryData.total = res.total
        this.tableList = res.rows
      },
      /**
       * form置空事件
       */
      formClear(key) {
        this.queryData[key] = null
        this.onSubmit()
      }
    }
  }
</script>

<style scoped>

</style>
